package com.infonam.data.source.model;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name="film", catalog="sakila")
public class Film {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="film_id", nullable=false, unique=true)
	private int film_id;
	@Column(name="title")
	private String title;
	@Column(name="description")
	private String description;
	@Column(name="release_year")
	private int release_year;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="language_id")
	private int language_id;
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="original_language_id", referencedColumnName="original_language_id")
	private int original_language_id;
	@Column(name="rental_duration")
	private short rental_duration;
	@Column(name="rental_rate")
	private float rental_rate;
	@Column(name="replacement_cost")
	private float	replacement_cost;
	@Column(name="rating")
	private String 	rating;
	@Column(name="special_features")
	private String special_features;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="last_update" , columnDefinition="TIMESTAMP default CURRENT_TIMESTAMP on update TIMESTAMP")
	private Date last_update;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="pk.film")
	@Cascade({CascadeType.ALL})
	private List<FilmCategory> filmCategories = new LinkedList<FilmCategory>();
	@OneToMany(fetch=FetchType.LAZY, mappedBy="pk.film.actor")
	@Cascade({CascadeType.ALL})
	private List<FilmActor> listFilmActor = new LinkedList<FilmActor>();
	public int getFilm_id() {
		return film_id;
	}
	public void setFilm_id(int film_id) {
		this.film_id = film_id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public int getRelease_year() {
		return release_year;
	}
	public void setRelease_year(int release_year) {
		this.release_year = release_year;
	}
	public int getLanguage_id() {
		return language_id;
	}
	public void setLanguage_id(short language_id) {
		this.language_id = language_id;
	}
	public int getOriginal_language_id() {
		return original_language_id;
	}
	public void setOriginal_language_id(int original_language_id) {
		this.original_language_id = original_language_id;
	}
	public short getRental_duration() {
		return rental_duration;
	}
	public void setRental_duration(short rental_duration) {
		this.rental_duration = rental_duration;
	}
	public float getRental_rate() {
		return rental_rate;
	}
	public void setRental_rate(float rental_rate) {
		this.rental_rate = rental_rate;
	}
	public float getReplacement_cost() {
		return replacement_cost;
	}
	public void setReplacement_cost(float replacement_cost) {
		this.replacement_cost = replacement_cost;
	}
	public String getRating() {
		return rating;
	}
	public void setRating(String rating) {
		this.rating = rating;
	}
	public Date getLast_update() {
		return last_update;
	}
	public void setLast_update(Date last_update) {
		this.last_update = last_update;
	}
	public List<FilmCategory> getFilmCategories() {
		return filmCategories;
	}
	public void setFilmCategories(List<FilmCategory> filmCategories) {
		this.filmCategories = filmCategories;
	}
	public List<FilmActor> getListFilmActor() {
		return listFilmActor;
	}
	public void setListFilmActor(List<FilmActor> listFilmActor) {
		this.listFilmActor = listFilmActor;
	}
	public String getSpecial_features() {
		return special_features;
	}
	public void setSpecial_features(String special_features) {
		this.special_features = special_features;
	}
}
